home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_58064.txt < prev    next >
Text File  |  1991-02-27  |  900b  |  28 lines

  1. -- card: 58064 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10. The fclose() function should be used to close the stream and its associated file after use.  For example, to write text to the file 'output.fil':
  11.  
  12.     # include  <stdio.h>
  13.                 .
  14.                 .
  15.         FILE   *fp;                 /* declare pointer to a FILE type */
  16.         fp = fopen("output.fil","w");       /* creates new file if non-existant */
  17.         if (fp != NULL)
  18.         {   fprintf(fp,"Here's some output: %d\n",99);
  19.             fclose(fp);
  20.         }
  21.  
  22. Note that fopen() returns the NULL pointer (defined in stdio.h) if it is unable to open the stream.
  23.  
  24. There are many other useful standard I/O functions available for binary I/O, non-sequential access, etc.
  25.  
  26. -- part contents for background part 7
  27. ----- text -----
  28. 192